﻿using UnityEngine;
using System.Collections;

public class DropOffTruckLogic : BaseEnemy
{
	int numberOfenemiesdropped = 0;
	int numberOfEnemiesToDropOff = 5;
	float dropOffTimer = 0.0f;
	float DropOffTimerMax = 5.0f;
	Vector2 DropOffTimerRange = new Vector2(2.0f, 15.0f);
	public GameObject landTroopPrefab;


	protected override void SetUp()
	{
		health = 30.0f;
		minNumOfCoins = 5;
		maxNumOfCoins = 15;
		minAttackDistance = 1.0f;
	}

	protected override void PersonalUpdate ()
	{
		if(numberOfenemiesdropped < numberOfEnemiesToDropOff)
		{
			dropOffTimer += Time.deltaTime;
			if(dropOffTimer >= DropOffTimerMax)
			{
				numberOfenemiesdropped ++;
				DropOffLandTroop ();
				dropOffTimer = 0.0f;
				DropOffTimerMax = Random.Range (DropOffTimerRange.x, DropOffTimerRange.y);
			}
		}
		else
		{
			Die ();
		}

	}

	void DropOffLandTroop()
	{
		mySpawner.CreateEnemy (landTroopPrefab, (transform.position - transform.forward));
	}


}
